package com.mc.designpattern.template;

import com.mc.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping()
public class TemplateController {
    @Autowired
    TemplateProcessor processor;
    @Resource(name = "file1Log")
    private AbstractLog abstractLog;
    @Resource(name = "file2Log")
    private AbstractLog abstractLog2;

    @GetMapping("/handler/testTemplate")
    @ResponseBody
    public Result handleOrder() {

        List<AbstractLog> all = processor.getAll();
        for (AbstractLog abstractLog : all) {
            abstractLog.doLog("12344");

        }
        return Result.success(null);
    }

    @RequestMapping("/helloSuccess1111")
    public Result helloSuccess() {
        abstractLog.log("file1Log");
        abstractLog2.log("file2Log");
        return Result.success("hello");
    }


}
